package com.adapter.kdi;

import java.util.ArrayList;

import com.example.kdi.R;
import com.adapter.kdi.EnseigneIco;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class EnseigneAdapter extends ArrayAdapter<EnseigneIco>{

    Context context;
    int layoutResourceId;   
    ArrayList<EnseigneIco> data= null;
   
    public EnseigneAdapter(Context context, int layoutResourceId, ArrayList<EnseigneIco> item_ico) {
        super(context, layoutResourceId, item_ico);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = item_ico;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        EnseigneIcoHolder holder = null;
       
        if(row == null)
        {
            LayoutInflater inflater = ((Activity)context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);
           
            holder = new EnseigneIcoHolder();
            holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
            //holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
           
            row.setTag(holder);
        }
        else
        {
            holder = (EnseigneIcoHolder)row.getTag();
        }
       
        EnseigneIco EnseigneIco = data.get(position);
        //holder.txtTitle.setText(EnseigneIco.title);
        holder.imgIcon.setImageResource(EnseigneIco.icon);
       
        return row;
    }
   
    static class EnseigneIcoHolder
    {
        ImageView imgIcon;
        TextView txtTitle;
    }
}
